<?php
header('Content-type: application/xls');
header('Content-Disposition:attachment;filename=dssinhvien.xls');
?>
<h2>Danh sách sinh viên</h2>
<p>Ngày: <?php echo date('d-m-Y')?></p>
<table cellpadding="0" cellspacing="0">
	<tr>
	<?php foreach ($cothienthi as $tencot):?>
			<th><?php echo $tencot?></th>
	<?php endforeach;?>
	</tr>
	<?php
	$i = 0;
	foreach ($sinhviens as $sinhvien):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
		<?php foreach ($cothienthi as $keycot => $tencot):?>
		<td>
			<?php
				if($keycot=='tendantoc')
					if(isset($sinhvien['Z1sinhvien'][$keycot])) 
						echo $sinhvien['Z1sinhvien'][$keycot];
					else
						echo $sinhvien['dantoc'][$keycot];
				elseif($keycot=='tentinhtp')
					if(isset($sinhvien['Z1sinhvien'][$keycot])) 
						echo $sinhvien['Z1sinhvien'][$keycot];
					else
						echo $sinhvien['tinhtp'][$keycot];
				elseif($keycot=='tennganh')
					if(isset($sinhvien['Z1sinhvien'][$keycot])) 
						echo $sinhvien['Z1sinhvien'][$keycot];
					else
						echo $sinhvien['nganh'][$keycot];  
				else
					echo $sinhvien['Z1sinhvien'][$keycot];
			?>
		</td>
		<?php endforeach;?>
	</tr>
<?php endforeach; ?>
	</table>